﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class TriggerBattle : MonoBehaviour {

    public string Id;
    public int Num = 1;
    private LoadingPanel LoadingPanel;

    // Use this for initialization
    void Start () {
        this.LoadingPanel = GameObject.Find("LoadingPanel").GetComponent<LoadingPanel>();
    }
	
	// Update is called once per frame
	void Update () {
        
	}

    private void OnTriggerEnter(Collider other) {
        GlobalData globalData = GlobalData.Instance;
        if (other.CompareTag("Player")) { // 碰到主角
            if (globalData.IsEscaping) { // 正在逃跑
                globalData.IsEscaping = false;
                return;
            }
            globalData.TriggerName = gameObject.name;
            globalData.EnemyTeam = new List<Personage>();
            globalData.EnemyTeam.Add(PersonageManager.initPersonage("阿", "大"));
            if (Num > 1) {
                globalData.EnemyTeam.Add(PersonageManager.initPersonage("阿", "二"));
            }
            if (Num > 2) {
                globalData.EnemyTeam.Add(PersonageManager.initPersonage("阿", "三"));
            }
            GameManager.Instance.UpdatePlayer(other.transform);
            this.LoadingPanel.LoadScene("Fight");
        }
    }

}
